<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>





        获取非行内样式  
        兼容写法

        if (window.getComputedStyle) {  //常规浏览器
            // console.log(window.getComputedStyle(demo));
            console.log(window.getComputedStyle(demo).width);
        } else {  // IE低版本
            // console.log(demo.currentStyle);
            console.log(demo.currentStyle.width);
        }
        
        function getStyle(ele, key) {
            if (window.getComputedStyle) {
                return window.getComputedStyle(ele)[key];
            } else {
                return ele.currentStyle[key];
            }
        }






    </script>
</body>

</html>